/*
 ***************************************************************************
 * MediaTeK Inc.
 * 4F, No. 2 Technology	5th	Rd.
 * Science-based Industrial	Park
 * Hsin-chu, Taiwan, R.O.C.
 *
 * (c) Copyright 2002-2012, MTK.
 *
 * All rights reserved.	MediaTeK's source	code is	an unpublished work	and	the
 * use of a	copyright notice does not imply	otherwise. This	source code
 * contains	confidential trade secret material of MediaTeK Tech. Any attemp
 * or participation	in deciphering,	decoding, reverse engineering or in	any
 * way altering	the	source code	is stricitly prohibited, unless	the	prior
 * written consent of MediaTeK, Inc. is obtained.
 ***************************************************************************

	Module Name:
	omci_me_ethernet_services_func.c

	Abstract:

	Revision History:
	Who			When			What
	--------	----------		----------------------------------------------
	Name		Date			Modification logs
	lisa.xue	2012/7/28	Create
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "omci_adpt_common.h"
#include "omci_adpt_general.h"
#include "libcompileoption.h"
#include "blapi_traffic.h"

int getPPTPEthernetUNIAutoDetectConfig(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setPPTPEthernetUNIAutoDetectConfig(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int getPPTPEthernetUNIEthernetLoopbackCfg(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setPPTPEthernetUNIEthernetLoopbackCfg(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setPPTPEthernetUNIAdminStateValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int getPPTPEthernetUNICfgIndValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int getPPTPEthernetUNIMaxFrameSize(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setPPTPEthernetUNIMaxFrameSize(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int getPPTPEthernetUNIPauseTime(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setPPTPEthernetUNIPauseTime(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setPPTPEthernetUNIARCValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);

int setVirtualEthernetInterfacePointAdminStateValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int getVirtualEthernetInterfacePointOpStateValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int getVirtualEthernetInterfacePointIANAAssignedPortValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setVirtualEthernetInterfacePointInterDomain(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);

int xsi_lanport_info_covert(int portId);

/*******************************************************************************************************************************
9.5.1 PPTP Ethernet UNI

********************************************************************************************************************************/
static attribute_func_t ethernetPPTPUNIAutoDetectConfigFunc = {
	getPPTPEthernetUNIAutoDetectConfig,
	setPPTPEthernetUNIAutoDetectConfig
};
static attribute_func_t ethernetPPTPUNIEthernetLoopbackCfgFunc = {
	getPPTPEthernetUNIEthernetLoopbackCfg,
	setPPTPEthernetUNIEthernetLoopbackCfg
};

static attribute_func_t ethernetPPTPUNIAdminStateFunc = {
	NULL,	//getPPTPEthernetUNIAdminStateValue, not need in OMCI2.0
	setPPTPEthernetUNIAdminStateValue
};

static attribute_func_t ethernetPPTPUNICfgIndFunc = {
	getPPTPEthernetUNICfgIndValue,
	NULL
};

static attribute_func_t ethernetPPTPUNIMaxFrameSizeFunc = {
	getPPTPEthernetUNIMaxFrameSize,
	setPPTPEthernetUNIMaxFrameSize
};

static attribute_func_t ethernetPPTPUNIPauseTimeFunc = {
	getPPTPEthernetUNIPauseTime,
	setPPTPEthernetUNIPauseTime
};

static attribute_func_t ethernetPPTPUNIARCFunc = {
	NULL,
	setPPTPEthernetUNIARCValue
};

static attribute_func_t ethernetPPTPUNIARCIntervalFunc = {
	NULL,
	NULL,//	setPPTPEthernetUNIARCIntervalValue, not need in OMCI2.0
};

static attribute_func_t ethernetPPTPUNIPPPoEFilterFunc = {
	NULL,
	NULL,//	setPPTPEthernetUNIPPPoEFilter, not need in OMCI2.0
};

omci_attr_dscp_t omci_attr_pptp_eth_uni_op[]={
{0, "meId",						2,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,&generalAttrFunc},
{1, "expected type",			1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,&generalAttrFunc},
{2, "sensed type",				1,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,&generalAttrFunc},
{3, "auto detection config",	1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_ENUM,            ATTR_FULLY_SUPPORT,&ethernetPPTPUNIAutoDetectConfigFunc},
{4, "ethernet loopback config",	1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_ENUM,            ATTR_FULLY_SUPPORT,&ethernetPPTPUNIEthernetLoopbackCfgFunc},
{5, "admin state",				1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_ENUM,            ATTR_FULLY_SUPPORT,&ethernetPPTPUNIAdminStateFunc},
{6, "operational state",		1,  ATTR_ACCESS_R,      ATTR_FORMAT_ENUM,            ATTR_FULLY_SUPPORT,&generalAttrFunc},
{7, "configuration ind",		1,  ATTR_ACCESS_R,      ATTR_FORMAT_ENUM,            ATTR_FULLY_SUPPORT,&ethernetPPTPUNICfgIndFunc},
{8, "max frame size",			2,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,&ethernetPPTPUNIMaxFrameSizeFunc},
{9, "dte or dce ind",			1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_ENUM,            ATTR_FULLY_SUPPORT,&generalAttrFunc},
{10, "pause time",				2,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,&ethernetPPTPUNIPauseTimeFunc},
{11, "Bridged or IP ind",		1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_ENUM,            ATTR_FULLY_SUPPORT,&generalAttrFunc},
{12, "ARC",						1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,&ethernetPPTPUNIARCFunc},
{13, "ARC interval",			1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,&ethernetPPTPUNIARCIntervalFunc},
{14, "pppoe filter",			1 , ATTR_ACCESS_R_W,    ATTR_FORMAT_ENUM,            ATTR_FULLY_SUPPORT, &ethernetPPTPUNIPPPoEFilterFunc},
{15, "power control",			1 , ATTR_ACCESS_R_W,    ATTR_FORMAT_ENUM,            ATTR_FULLY_SUPPORT, &generalAttrFunc},
{255, "", 						0,  0, 0, 0, NULL}
};

omci_me_func_t omci_me_pptp_eth_uni_op ={
	NULL,
	NULL,
	omci_me_general_set_op,
	omci_me_general_get_op,
};

omci_pptp_eth_uni_t omci_pptp_eth_uni_attr_data = {0};

omci_attr_t omci_pptp_eth_uni_attr ={
	(uint8_t *)&omci_pptp_eth_uni_attr_data,
	sizeof(omci_pptp_eth_uni_attr_data)
};

/*******************************************************************************************************************************
9.5.2 Ethernet performance monitoring history data

********************************************************************************************************************************/
omci_attr_dscp_t omci_attr_eth_pm_his_op[]={
{0, "meId",							2,  ATTR_ACCESS_R_SET_CREATE,       ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{1, "interval end time",			1,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{2, "threshold data 1/2 id",		2,  ATTR_ACCESS_R_W_SET_CREATE,     ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{3, "fcs errors",					4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{4, "excessive collision cnt",		4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{5, "late collision cnt",			4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{6, "frames too long",				4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{7, "Buffer overflows on receive",	4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{8, "Buffer overflows on transmit",	4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{9, "single collision frame cnt",	4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{10, "multi collisions frame cnt",	4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{11, "sqe counter",					4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{12, "deferred transmission cnt",	4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{13, "internal mac trans error cnt",4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{14, "carrier sense error cnt",		4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{15, "alignment error cnt",			4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, 	&generalAttrFunc},
{16, "internal mac recv error cnt",	4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{255, "",							0, 	0, 0, 0, NULL}
};

int get_pptp_eth_uni_data(PPTPEthernetUNIPmcounters_t *data, uint16_t instId)
{
	uint32_t cnt = 0;
	int validPortId = 0;

	if(data == NULL)
	{
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]pointer is NULL.\n",__FUNCTION__,__LINE__);
        return -1;
    }

	memset(data, 0, sizeof(PPTPEthernetUNIPmcounters_t));
	validPortId = getPortIdxByInstId(instId);

	if(validPortId <= 0 || validPortId > LANPORT_INFO_MAX_PORT)  
	{
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]validPortId error.\n",__FUNCTION__,__LINE__);
        return -1;
	}
	validPortId--;
	if(pSystemCap->ethType[validPortId] == UNIT_TYPE_BASET_10100 ||pSystemCap->ethType[validPortId] == UNIT_TYPE_BASET_101001000 ) {
		if(macMT7530GetFCSErrors(validPortId, &cnt) == 0){
			data->FCSErrors = cnt;
		}
		if(macMT7530GetExcessiveCollisionCounter(validPortId, &cnt) == 0){
			data->excessiveCollisionCnts = cnt;
		}
		if(macMT7530GetLateCollisionCounter(validPortId, &cnt) == 0){
			data->lateCollisionCnts = cnt;
		}	
		if(macMT7530GetFramesTooLong(validPortId, &cnt) == 0){
			data->framesTooLong = cnt;
		}
		if(macMT7530GetBufferOverflowsRx(validPortId, &cnt) == 0){
			data->bufferOverFlowOnRcv = cnt;
		}	
		if(macMT7530GetSingleCollisionFrameCounter(validPortId, &cnt) == 0){
			data->singleCollisionFrameCnts = cnt;
		}
		if(macMT7530GetMultipleCollisionsFrameCounter(validPortId, &cnt) == 0){
			data->multiCollisionFrameCnts = cnt;
		}	
		if(macMT7530GetDeferredTxCounter(validPortId, &cnt) == 0){
			data->deferredTransmissionCnts = cnt;
		}	
		if(macMT7530GetAlignmentErrorCounter(validPortId, &cnt) == 0){
			data->alignmentErrorCnts = cnt;
		}
	}
	else if(pSystemCap->ethType[validPortId] == UNIT_TYPE_ETHER_2500) {
		;			//8811 do not support these conters
	}
	else if(pSystemCap->ethType[validPortId] == UNIT_TYPE_ETHER_10G) {
		;			//to be implemented
	}
	return 0;
}


int get_eth_pm_history_data(pm_history_data_list_ptr pm_list, uint8_t syncFlag)
{
    PPTPEthernetUNIPmcounters_t pptpEthUni ={0};

    if(pm_list == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  pm_list is NULL fail\n",__FUNCTION__,__LINE__);
        return -1;
    }

    if(get_pptp_eth_uni_data(&pptpEthUni, pm_list->instId) != 0) {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  get_pptp_eth_uni_data fail\n",__FUNCTION__,__LINE__);
        return -1;
    }

    if(syncFlag)
    {
        pm_list->pm_data.eth_pm.interEndTime = pmIntervalTimes;
    	pm_list->pm_data.eth_pm.fcsErr = pptpEthUni.FCSErrors - pm_list->pm_prev_data.pptpEthUni.FCSErrors;
    	pm_list->pm_data.eth_pm.excesCollisCnt = pptpEthUni.excessiveCollisionCnts - pm_list->pm_prev_data.pptpEthUni.excessiveCollisionCnts;
    	pm_list->pm_data.eth_pm.lateCollisCnt = pptpEthUni.lateCollisionCnts - pm_list->pm_prev_data.pptpEthUni.lateCollisionCnts;
    	pm_list->pm_data.eth_pm.frameTooLong = pptpEthUni.framesTooLong - pm_list->pm_prev_data.pptpEthUni.framesTooLong;
    	pm_list->pm_data.eth_pm.bufOverOnReceive = pptpEthUni.bufferOverFlowOnRcv - pm_list->pm_prev_data.pptpEthUni.bufferOverFlowOnRcv;
    	pm_list->pm_data.eth_pm.bufOverOnTrans = 0;
    	pm_list->pm_data.eth_pm.singleCollisFrameCnt = pptpEthUni.singleCollisionFrameCnts - pm_list->pm_prev_data.pptpEthUni.singleCollisionFrameCnts;
    	pm_list->pm_data.eth_pm.multiCollisFrameCnt = pptpEthUni.multiCollisionFrameCnts - pm_list->pm_prev_data.pptpEthUni.multiCollisionFrameCnts;
    	pm_list->pm_data.eth_pm.sqeCnt = 0;
    	pm_list->pm_data.eth_pm.deferTransCnt = pptpEthUni.deferredTransmissionCnts - pm_list->pm_prev_data.pptpEthUni.deferredTransmissionCnts;
    	pm_list->pm_data.eth_pm.interMACTransErrCnt= 0;
    	pm_list->pm_data.eth_pm.carrSenseErrCnt = 0;
    	pm_list->pm_data.eth_pm.alignErrCnt= pptpEthUni.alignmentErrorCnts - pm_list->pm_prev_data.pptpEthUni.alignmentErrorCnts;
    	pm_list->pm_data.eth_pm.interMACRcvErrCnt= 0;

    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->fcsErr = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth_pm.fcsErr);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->excesCollisCnt = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth_pm.excesCollisCnt);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->lateCollisCnt = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth_pm.lateCollisCnt);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->frameTooLong = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth_pm.frameTooLong);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->bufOverOnReceive = 0x%x\n",__FUNCTION__,__LINE__,pm_list->pm_data.eth_pm.bufOverOnReceive);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->bufOverOnTrans = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth_pm.bufOverOnTrans);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->singleCollisFrameCnt = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth_pm.singleCollisFrameCnt);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->multiCollisFrameCnt = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth_pm.multiCollisFrameCnt);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->sqeCnt = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth_pm.sqeCnt);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->deferTransCnt = 0x%x\n",__FUNCTION__,__LINE__,pm_list->pm_data.eth_pm.deferTransCnt);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->interMACTransErrCnt = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth_pm.interMACTransErrCnt);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->carrSenseErrCnt = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth_pm.carrSenseErrCnt);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->alignErrCnt = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth_pm.alignErrCnt);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->interMACRcvErrCnt = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth_pm.interMACRcvErrCnt);
        
    }

    memcpy(&pm_list->pm_prev_data.pptpEthUni, &pptpEthUni, sizeof(PPTPEthernetUNIPmcounters_t));

    omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->FCSErrors = 0x%x\n",__FUNCTION__,__LINE__, pptpEthUni.FCSErrors);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->excessiveCollisionCnts = 0x%x\n",__FUNCTION__,__LINE__, pptpEthUni.excessiveCollisionCnts);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->lateCollisionCnts = 0x%x\n",__FUNCTION__,__LINE__, pptpEthUni.lateCollisionCnts);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->framesTooLong = 0x%x\n",__FUNCTION__,__LINE__, pptpEthUni.framesTooLong);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->bufferOverFlowOnRcv = 0x%x\n",__FUNCTION__,__LINE__,pptpEthUni.bufferOverFlowOnRcv);
    omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->singleCollisionFrameCnts = 0x%x\n",__FUNCTION__,__LINE__, pptpEthUni.singleCollisionFrameCnts);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->multiCollisionFrameCnts = 0x%x\n",__FUNCTION__,__LINE__, pptpEthUni.multiCollisionFrameCnts);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->deferredTransmissionCnts = 0x%x\n",__FUNCTION__,__LINE__, pptpEthUni.deferredTransmissionCnts);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->alignmentErrorCnts = 0x%x\n",__FUNCTION__,__LINE__,pptpEthUni.alignmentErrorCnts);

    return 0;
}




int omci_me_eth_pm_history_get_curr_op(management_entry_ptr me_entry, omci_me_info_ptr me_info)
{
    omci_eth_pm_his_ptr eth_pm_new = NULL;
    PPTPEthernetUNIPmcounters_t pptpEthUni ={0};

    if(me_entry == NULL || me_info == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]pointer is NULL.\n",__FUNCTION__,__LINE__);
        return -1;
    }

    eth_pm_new = (omci_eth_pm_his_ptr)me_info->attributes;
    if(eth_pm_new == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]me info attribute is NULL.\n",__FUNCTION__,__LINE__);
        return -1;
    }
    if(get_pptp_eth_uni_data(&pptpEthUni, me_info->inst_id) != 0) {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  get_pptp_eth_uni_data fail\n",__FUNCTION__,__LINE__);
        return -1;
    }

	eth_pm_new->interEndTime = pmIntervalTimes;
	eth_pm_new->fcsErr = pptpEthUni.FCSErrors;
	eth_pm_new->excesCollisCnt = pptpEthUni.excessiveCollisionCnts;
	eth_pm_new->lateCollisCnt = pptpEthUni.lateCollisionCnts;
	eth_pm_new->frameTooLong = pptpEthUni.framesTooLong;
	eth_pm_new->bufOverOnReceive = pptpEthUni.bufferOverFlowOnRcv;
	eth_pm_new->bufOverOnTrans = 0;
	eth_pm_new->singleCollisFrameCnt = pptpEthUni.singleCollisionFrameCnts;
	eth_pm_new->multiCollisFrameCnt = pptpEthUni.multiCollisionFrameCnts;
	eth_pm_new->sqeCnt = 0;
	eth_pm_new->deferTransCnt = pptpEthUni.deferredTransmissionCnts;
	eth_pm_new->interMACTransErrCnt= 0;
	eth_pm_new->carrSenseErrCnt = 0;
	eth_pm_new->alignErrCnt= pptpEthUni.alignmentErrorCnts;
	eth_pm_new->interMACRcvErrCnt= 0;

	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->fcsErr = 0x%x\n",__FUNCTION__,__LINE__, eth_pm_new->fcsErr);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->excesCollisCnt = 0x%x\n",__FUNCTION__,__LINE__, eth_pm_new->excesCollisCnt);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->lateCollisCnt = 0x%x\n",__FUNCTION__,__LINE__, eth_pm_new->lateCollisCnt);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->frameTooLong = 0x%x\n",__FUNCTION__,__LINE__, eth_pm_new->frameTooLong);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->bufOverOnReceive = 0x%x\n",__FUNCTION__,__LINE__,eth_pm_new->bufOverOnReceive);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->bufOverOnTrans = 0x%x\n",__FUNCTION__,__LINE__, eth_pm_new->bufOverOnTrans);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->singleCollisFrameCnt = 0x%x\n",__FUNCTION__,__LINE__, eth_pm_new->singleCollisFrameCnt);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->multiCollisFrameCnt = 0x%x\n",__FUNCTION__,__LINE__, eth_pm_new->multiCollisFrameCnt);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->sqeCnt = 0x%x\n",__FUNCTION__,__LINE__, eth_pm_new->sqeCnt);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->deferTransCnt = 0x%x\n",__FUNCTION__,__LINE__,eth_pm_new->deferTransCnt);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->interMACTransErrCnt = 0x%x\n",__FUNCTION__,__LINE__, eth_pm_new->interMACTransErrCnt);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->carrSenseErrCnt = 0x%x\n",__FUNCTION__,__LINE__, eth_pm_new->carrSenseErrCnt);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->alignErrCnt = 0x%x\n",__FUNCTION__,__LINE__, eth_pm_new->alignErrCnt);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->interMACRcvErrCnt = 0x%x\n",__FUNCTION__,__LINE__, eth_pm_new->interMACRcvErrCnt);
	

    return 0;
}


int omci_me_eth_pm_history_notify(pm_history_data_list_ptr pm_list, omci_me_info_t threshold_info)
{
    enum{ ETH_PM_HISTORY_DATA_TCA_NUM = 14};
    #define THRESHOLD_DATA_MAX_THRESHOLD_NUM    7
    omci_threshold_data_1_ptr threshold_data1 = NULL;
    int i = 0;
    uint32_t currentData[ETH_PM_HISTORY_DATA_TCA_NUM] = {0};
    static uint8_t reportFlag[ETH_PM_HISTORY_DATA_TCA_NUM] = {0};
    uint8_t alarm_num[ETH_PM_HISTORY_DATA_TCA_NUM] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 , 13};
    tca_notify_info_t tca_info = {0};
    PPTPEthernetUNIPmcounters_t pptpEthUni ={0};
    int startIdx = 0;
    int endIdx = 0;
    int thresholdIdx = 0;
    
    if(pm_list == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  pm_list is NULL fail\n",__FUNCTION__,__LINE__);
        return -1;
    }
    if(omci_pm_is_end_of_interval_time())
    {
        memset(reportFlag, 0, sizeof(reportFlag));
        return 0;
    }
    if(threshold_info.class_id == OMCI_CLASS_ID_THRESHOLD_DATA1)
    {
        startIdx = 0;
        endIdx = THRESHOLD_DATA_MAX_THRESHOLD_NUM;
    }
    else if(threshold_info.class_id == OMCI_CLASS_ID_THRESHOLD_DATA2)
    {
        startIdx = THRESHOLD_DATA_MAX_THRESHOLD_NUM;
        endIdx = ETH_PM_HISTORY_DATA_TCA_NUM;
    }
    else{
        return 0;
    }

	threshold_data1 =  (omci_threshold_data_1_ptr)threshold_info.attributes;
	if(threshold_data1 == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  threshold value is NULL \n",__FUNCTION__,__LINE__);
        return -1;
    }
    if(get_pptp_eth_uni_data(&pptpEthUni, pm_list->instId) != 0) {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  get_pptp_eth_uni_data fail\n",__FUNCTION__,__LINE__);
        return -1;
    }
    /*monitor 15min interval tca attribute value*/
	currentData[0] = pptpEthUni.FCSErrors - pm_list->pm_prev_data.pptpEthUni.FCSErrors;
	currentData[1] = pptpEthUni.excessiveCollisionCnts - pm_list->pm_prev_data.pptpEthUni.excessiveCollisionCnts;
	currentData[2] = pptpEthUni.lateCollisionCnts - pm_list->pm_prev_data.pptpEthUni.lateCollisionCnts;
    currentData[3] = pptpEthUni.framesTooLong - pm_list->pm_prev_data.pptpEthUni.framesTooLong;
    currentData[4] = pptpEthUni.bufferOverFlowOnRcv - pm_list->pm_prev_data.pptpEthUni.bufferOverFlowOnRcv;
	currentData[5] = 0;
	currentData[6] = pptpEthUni.singleCollisionFrameCnts - pm_list->pm_prev_data.pptpEthUni.singleCollisionFrameCnts;
    currentData[7] = pptpEthUni.multiCollisionFrameCnts - pm_list->pm_prev_data.pptpEthUni.multiCollisionFrameCnts;
    currentData[8] = 0;
	currentData[9] = pptpEthUni.deferredTransmissionCnts - pm_list->pm_prev_data.pptpEthUni.deferredTransmissionCnts;
	currentData[10] = 0;
    currentData[11] = 0;
    currentData[12] = pptpEthUni.alignmentErrorCnts - pm_list->pm_prev_data.pptpEthUni.alignmentErrorCnts;
    currentData[13] = 0;
    

    for(i = startIdx; i < endIdx; i++)
    {
        thresholdIdx = i < THRESHOLD_DATA_MAX_THRESHOLD_NUM ? i : (i-THRESHOLD_DATA_MAX_THRESHOLD_NUM);
        tca_info.classId = pm_list->classId;
        tca_info.instId = pm_list->instId;
        tca_info.currentData = currentData[i];
        tca_info.threshold = threshold_data1->thresholdValue[thresholdIdx];
        tca_info.alarm_num = alarm_num[i];
        tca_info.reportFlag = reportFlag[i];

        reportFlag[i] = omci_pm_report_alarm_by_tca_info(tca_info, 0);
	}

	return 0;
    
}

omci_me_func_t omci_me_eth_pm_his_op ={
	omci_me_general_pm_history_create_del_op,
	omci_me_general_pm_history_create_del_op,
	omci_me_general_pm_history_set_op,
	omci_me_general_pm_history_get_op,
	omci_me_eth_pm_history_get_curr_op,
};

omci_eth_pm_his_t omci_eth_pm_his_attr_data = {0};

omci_attr_t omci_eth_pm_his_attr ={
	(uint8_t *)&omci_eth_pm_his_attr_data,
	sizeof(omci_eth_pm_his_attr_data)
};


/*******************************************************************************************************************************
9.5.3 Ethernet performance monitoring history data 2

********************************************************************************************************************************/
omci_attr_dscp_t omci_attr_eth_pm_his_2_op[]={
{0, "meId",							2,  ATTR_ACCESS_R_SET_CREATE,       ATTR_FORMAT_UNSIGNED_INT,   ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{1, "interval end time",			1,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,   ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{2, "threshold data 1/2 id",		2,  ATTR_ACCESS_R_W_SET_CREATE,     ATTR_FORMAT_UNSIGNED_INT,   ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{3, "pppoe filtered frame cnt",		4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,   ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{255, "", 							0, 	0, 0, 0, NULL}
};

int get_eth2_pm_history_data(pm_history_data_list_ptr pm_list, uint8_t syncFlag)
{
    if(pm_list == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  pm_list is NULL fail\n",__FUNCTION__,__LINE__);
        return -1;
    }
    if(syncFlag)
    {
        /*driver do not implement, so the value is 0*/
        pm_list->pm_data.eth2_pm.interEndTime= pmIntervalTimes;
    	pm_list->pm_data.eth2_pm.pppoeFilterFrameCnt = 0;
        omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->discardFrames = 0x%x\n",__FUNCTION__,__LINE__,pm_list->pm_data.eth2_pm.pppoeFilterFrameCnt);
    }
        
    return 0;
}

int omci_me_eth2_pm_history_get_curr_op(management_entry_ptr me_entry, omci_me_info_ptr me_info)
{
    omci_eth_pm_his_2_ptr eth2_pm_new = NULL;
    
    if(me_entry == NULL || me_info == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]pointer is NULL.\n",__FUNCTION__,__LINE__);
        return -1;
    }

    eth2_pm_new = (omci_eth_pm_his_2_ptr)me_info->attributes;
    if(eth2_pm_new == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]me info attribute is NULL.\n",__FUNCTION__,__LINE__);
        return -1;
    }
    /*driver do not implement, so the value is 0*/

	eth2_pm_new->interEndTime= pmIntervalTimes;
	eth2_pm_new->pppoeFilterFrameCnt= 0;

	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->discardFrames = 0x%x\n",__FUNCTION__,__LINE__, eth2_pm_new->pppoeFilterFrameCnt);
	

    return 0;
}


int omci_me_eth2_pm_history_notify(pm_history_data_list_ptr pm_list, omci_me_info_t threshold_info)
{
    enum{ ETH2_PM_HISTORY_DATA_TCA_NUM = 1};
    omci_threshold_data_1_ptr threshold_data1 = NULL;
    int i = 0;
    uint32_t currentData[ETH2_PM_HISTORY_DATA_TCA_NUM] = {0};
    static uint8_t reportFlag[ETH2_PM_HISTORY_DATA_TCA_NUM] = {0};
    uint8_t alarm_num[ETH2_PM_HISTORY_DATA_TCA_NUM] = {0};
    tca_notify_info_t tca_info = {0};

    if(pm_list == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  pm_list is NULL fail\n",__FUNCTION__,__LINE__);
        return -1;
    }
    if(omci_pm_is_end_of_interval_time())
    {
        memset(reportFlag, 0, sizeof(reportFlag));
        return 0;
    }
    if(threshold_info.class_id != OMCI_CLASS_ID_THRESHOLD_DATA1){
        return 0;
    }

	threshold_data1 =  (omci_threshold_data_1_ptr)threshold_info.attributes;
    if(threshold_data1 == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  threshold value is NULL \n",__FUNCTION__,__LINE__);
        return -1;
    }

    for(i = 0; i < ETH2_PM_HISTORY_DATA_TCA_NUM; i++)
    {
        tca_info.classId = pm_list->classId;
        tca_info.instId = pm_list->instId;
        tca_info.currentData = currentData[i];
        tca_info.threshold = threshold_data1->thresholdValue[i];
        tca_info.alarm_num = alarm_num[i];
        tca_info.reportFlag = reportFlag[i];

        reportFlag[i] = omci_pm_report_alarm_by_tca_info(tca_info, 0);
	}

	return 0;
    
}


omci_me_func_t omci_me_eth_pm_his_2_op ={
	omci_me_general_pm_history_create_del_op,
	omci_me_general_pm_history_create_del_op,
	omci_me_general_pm_history_set_op,
	omci_me_general_pm_history_get_op,
	omci_me_eth2_pm_history_get_curr_op,
};

omci_eth_pm_his_2_t omci_eth_pm_his_2_attr_data = {0};

omci_attr_t omci_eth_pm_his_2_attr ={
	(uint8_t *)&omci_eth_pm_his_2_attr_data,
	sizeof(omci_eth_pm_his_2_attr_data)
};


/*******************************************************************************************************************************
9.5.4 Ethernet performance monitoring history data 3

********************************************************************************************************************************/
omci_attr_dscp_t omci_attr_eth_pm_his_3_op[]={
{0, "meId",							2,  ATTR_ACCESS_R_SET_CREATE,       ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{1, "interval end time",			1,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{2, "threshold data 1/2 id",		2,  ATTR_ACCESS_R_W_SET_CREATE,     ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{3, "drop events",					4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{4, "octets",						4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{5, "packets",						4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{6, "broadcast packets",			4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{7, "multicast packets",			4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{8, "undersize packets",			4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{9, "fragments",					4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{10, "jabbers",						4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{11, "packets 64 octets",			4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{12, "packets 65 to 127 octets",	4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{13, "packets 128 to 255 octets",	4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{14, "packets 256 to 511 octets",	4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{15, "packets 512 to 1023 octets",	4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{16, "packets 1024 to 1518 octets",	4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{255, "", 							0, 	0, 0, 0, NULL}
};

int get_pptp_eth3_uni_data(PPTPEthernetUNI3Pmcounters_t *data, uint16_t instId)
{
	uint32_t cnt = 0;
	int validPortId = 0;
	
	if(data == NULL)
	{
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]pointer is NULL.\n",__FUNCTION__,__LINE__);
        return -1;
    }

	memset(data, 0, sizeof(PPTPEthernetUNI3Pmcounters_t));
	validPortId = getPortIdxByInstId(instId);

	if(validPortId <= 0 || validPortId > LANPORT_INFO_MAX_PORT)
	{
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]validPortId error.\n",__FUNCTION__,__LINE__);
        return -1;
	}
	validPortId--;
	if(pSystemCap->ethType[validPortId] == UNIT_TYPE_BASET_10100 ||pSystemCap->ethType[validPortId] == UNIT_TYPE_BASET_101001000 ) {	
		if(macMT7530GetPortRxLackDropPktCnt(validPortId, &cnt) == 0){
			data->dropEvents = cnt;
		}
		if(macMT7530GetPortRxOctetsCnt(validPortId, &cnt) == 0){
			data->octets = cnt;
		}
		if(macMT7530GetPortRxPktsCnt(validPortId, &cnt) == 0){
			data->packets = cnt;
		}
		if(macMT7530GetPortRxBroadPktsCnt(validPortId, &cnt) == 0){
			data->broadcastPkts = cnt;
		}
		if(macMT7530GetPortRxMultiPktsCnt(validPortId, &cnt) == 0){
			data->multicastPkts = cnt;
		}
		if(macMT7530GetPortRxUnderSizePktsCnt(validPortId, &cnt) == 0){
			data->undersizePkts = cnt;
		}
		if(macMT7530GetFragments(validPortId, &cnt) == 0){
			data->fragments = cnt;
		}
		if(macMT7530GetJabbers(validPortId, &cnt) == 0){
			data->jabbers = cnt;
		}
		if(macMT7530GetPortRx64PktsCnt(validPortId, &cnt) == 0){
			data->pkts64Octets = cnt;
		}
		if(macMT7530GetPortRx127PktsCnt(validPortId, &cnt) == 0){
			data->pkts65To127Octets = cnt;
		}	
		if(macMT7530GetPortRx255PktsCnt(validPortId, &cnt) == 0){
			data->pkts128To255Octets = cnt;
		}
		if(macMT7530GetPortRx511PktsCnt(validPortId, &cnt) == 0){
			data->pkts256To511Octets = cnt;
		}
		if(macMT7530GetPortRx1023PktsCnt(validPortId, &cnt) == 0){
			data->pkts512To1023Octets = cnt;
		}
		if(macMT7530GetPortRx1518PktsCnt(validPortId, &cnt) == 0){
			data->pkts1024To1518Octets = cnt;
		}
	}
	else if(pSystemCap->ethType[validPortId] == UNIT_TYPE_ETHER_2500) {
		ECNT_TRAFFIC_WAN_RX_STATISTICS rx_stats;
		memset(&rx_stats, 0x0, sizeof(rx_stats));
	
		if(blapi_traffic_get_hsgmii_lan_rx_statistics(&rx_stats,3) < 0)
		{
			omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]blapi_traffic_get_hsgmii_lan_rx_statistics fail.\n",__FUNCTION__,__LINE__);
			return -1;
		}
		data->dropEvents = rx_stats.drop_cnt;
		data->octets = rx_stats.frame_len;
		data->packets = rx_stats.frame_cnt;
		data->broadcastPkts = rx_stats.broadcast;
		data->multicastPkts = rx_stats.multicast;
		data->undersizePkts = rx_stats.undersize;
		data->fragments = rx_stats.fragment;
		data->jabbers = rx_stats.jabber;
		data->pkts64Octets = rx_stats.eq_64;
		data->pkts65To127Octets = rx_stats.from_65_to_127;
		data->pkts128To255Octets = rx_stats.from_128_to_255;
		data->pkts256To511Octets = rx_stats.from_256_to_511;
		data->pkts512To1023Octets = rx_stats.from_512_to_1023;
		data->pkts1024To1518Octets = rx_stats.from_1024_to_1518;
	}
	else if(pSystemCap->ethType[validPortId] == UNIT_TYPE_ETHER_10G) {
		;			//to be implemented
	}

	return 0;
}


int get_eth3_pm_history_data(pm_history_data_list_ptr pm_list, uint8_t syncFlag)
{
    PPTPEthernetUNI3Pmcounters_t pptpEth3Uni ={0};

    if(pm_list == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  pm_list is NULL fail\n",__FUNCTION__,__LINE__);
        return -1;
    }

    if(get_pptp_eth3_uni_data(&pptpEth3Uni, pm_list->instId) != 0) {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  get_pptp_eth_uni_data fail\n",__FUNCTION__,__LINE__);
        return -1;
    }

    if(syncFlag)
    {
        pm_list->pm_data.eth3_pm.interEndTime= pmIntervalTimes;
    	pm_list->pm_data.eth3_pm.dropEvent= pptpEth3Uni.dropEvents- pm_list->pm_prev_data.pptpEth3Uni.dropEvents;
    	pm_list->pm_data.eth3_pm.octets= pptpEth3Uni.octets- pm_list->pm_prev_data.pptpEth3Uni.octets;
    	pm_list->pm_data.eth3_pm.packets= pptpEth3Uni.packets- pm_list->pm_prev_data.pptpEth3Uni.packets;
    	pm_list->pm_data.eth3_pm.broadPackets= pptpEth3Uni.broadcastPkts- pm_list->pm_prev_data.pptpEth3Uni.broadcastPkts;
    	pm_list->pm_data.eth3_pm.multiPackets= pptpEth3Uni.multicastPkts- pm_list->pm_prev_data.pptpEth3Uni.multicastPkts;
    	pm_list->pm_data.eth3_pm.underPackets= pptpEth3Uni.undersizePkts- pm_list->pm_prev_data.pptpEth3Uni.undersizePkts;
    	pm_list->pm_data.eth3_pm.fragments= pptpEth3Uni.fragments- pm_list->pm_prev_data.pptpEth3Uni.fragments;
    	pm_list->pm_data.eth3_pm.jabbers= pptpEth3Uni.jabbers- pm_list->pm_prev_data.pptpEth3Uni.jabbers;
    	pm_list->pm_data.eth3_pm.packets64= pptpEth3Uni.pkts64Octets- pm_list->pm_prev_data.pptpEth3Uni.pkts64Octets;
    	pm_list->pm_data.eth3_pm.packets65to127= pptpEth3Uni.pkts65To127Octets- pm_list->pm_prev_data.pptpEth3Uni.pkts65To127Octets;
    	pm_list->pm_data.eth3_pm.packets128to255= pptpEth3Uni.pkts128To255Octets- pm_list->pm_prev_data.pptpEth3Uni.pkts128To255Octets;
    	pm_list->pm_data.eth3_pm.packets256to511= pptpEth3Uni.pkts256To511Octets- pm_list->pm_prev_data.pptpEth3Uni.pkts256To511Octets;
    	pm_list->pm_data.eth3_pm.packets512to1023= pptpEth3Uni.pkts512To1023Octets- pm_list->pm_prev_data.pptpEth3Uni.pkts512To1023Octets;
    	pm_list->pm_data.eth3_pm.packets1024to1518= pptpEth3Uni.pkts1024To1518Octets- pm_list->pm_prev_data.pptpEth3Uni.pkts1024To1518Octets;

    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->dropEvent = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth3_pm.dropEvent);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->octets = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth3_pm.octets);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->packets = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth3_pm.packets);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->broadPackets = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth3_pm.broadPackets);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->multiPackets = 0x%x\n",__FUNCTION__,__LINE__,pm_list->pm_data.eth3_pm.multiPackets);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->underPackets = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth3_pm.underPackets);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->fragments = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth3_pm.fragments);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->jabbers = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth3_pm.jabbers);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->packets64 = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth3_pm.packets64);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->packets65to127 = 0x%x\n",__FUNCTION__,__LINE__,pm_list->pm_data.eth3_pm.packets65to127);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->packets128to255 = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth3_pm.packets128to255);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->packets256to511 = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth3_pm.packets256to511);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->packets512to1023 = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth3_pm.packets512to1023);
    	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]15min->packets1024to1518 = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_data.eth3_pm.packets1024to1518);
        
    }

    memcpy(&pm_list->pm_prev_data.pptpEth3Uni, &pptpEth3Uni, sizeof(PPTPEthernetUNI3Pmcounters_t));

    omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->dropEvent = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_prev_data.pptpEth3Uni.dropEvents);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->octets = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_prev_data.pptpEth3Uni.octets);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->packets = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_prev_data.pptpEth3Uni.packets);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->broadPackets = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_prev_data.pptpEth3Uni.broadcastPkts);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->multiPackets = 0x%x\n",__FUNCTION__,__LINE__,pm_list->pm_prev_data.pptpEth3Uni.multicastPkts);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->underPackets = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_prev_data.pptpEth3Uni.undersizePkts);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->fragments = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_prev_data.pptpEth3Uni.fragments);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->jabbers = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_prev_data.pptpEth3Uni.jabbers);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->packets64 = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_prev_data.pptpEth3Uni.pkts64Octets);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->packets65to127 = 0x%x\n",__FUNCTION__,__LINE__,pm_list->pm_prev_data.pptpEth3Uni.pkts65To127Octets);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->packets128to255 = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_prev_data.pptpEth3Uni.pkts128To255Octets);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->packets256to511 = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_prev_data.pptpEth3Uni.pkts256To511Octets);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->packets512to1023 = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_prev_data.pptpEth3Uni.pkts512To1023Octets);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->packets1024to1518 = 0x%x\n",__FUNCTION__,__LINE__, pm_list->pm_prev_data.pptpEth3Uni.pkts1024To1518Octets);
        
    return 0;
}




int omci_me_eth3_pm_history_get_curr_op(management_entry_ptr me_entry, omci_me_info_ptr me_info)
{
    omci_eth_pm_his_3_ptr eth3_pm_new = NULL;
    PPTPEthernetUNI3Pmcounters_t pptpEth3Uni ={0};

    if(me_entry == NULL || me_info == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]pointer is NULL.\n",__FUNCTION__,__LINE__);
        return -1;
    }

    eth3_pm_new = (omci_eth_pm_his_3_ptr)me_info->attributes;
    if(eth3_pm_new == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]me info attribute is NULL.\n",__FUNCTION__,__LINE__);
        return -1;
    }
    if(get_pptp_eth3_uni_data(&pptpEth3Uni, me_info->inst_id) != 0) {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  get_pptp_eth_uni_data fail\n",__FUNCTION__,__LINE__);
        return -1;
    }

	eth3_pm_new->interEndTime= pmIntervalTimes;
	eth3_pm_new->dropEvent= pptpEth3Uni.dropEvents;
	eth3_pm_new->octets= pptpEth3Uni.octets;
	eth3_pm_new->packets= pptpEth3Uni.packets;
	eth3_pm_new->broadPackets= pptpEth3Uni.broadcastPkts;
	eth3_pm_new->multiPackets= pptpEth3Uni.multicastPkts;
	eth3_pm_new->underPackets= pptpEth3Uni.undersizePkts;
	eth3_pm_new->fragments= pptpEth3Uni.fragments;
	eth3_pm_new->jabbers= pptpEth3Uni.jabbers;
	eth3_pm_new->packets64= pptpEth3Uni.pkts64Octets;
	eth3_pm_new->packets65to127= pptpEth3Uni.pkts65To127Octets;
	eth3_pm_new->packets128to255= pptpEth3Uni.pkts128To255Octets;
	eth3_pm_new->packets256to511= pptpEth3Uni.pkts256To511Octets;
	eth3_pm_new->packets512to1023= pptpEth3Uni.pkts512To1023Octets;
	eth3_pm_new->packets1024to1518= pptpEth3Uni.pkts1024To1518Octets;

	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->dropEvent = 0x%x\n",__FUNCTION__,__LINE__, eth3_pm_new->dropEvent);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->octets = 0x%x\n",__FUNCTION__,__LINE__, eth3_pm_new->octets);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->packets = 0x%x\n",__FUNCTION__,__LINE__, eth3_pm_new->packets);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->broadPackets = 0x%x\n",__FUNCTION__,__LINE__, eth3_pm_new->broadPackets);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->multiPackets = 0x%x\n",__FUNCTION__,__LINE__, eth3_pm_new->multiPackets);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->underPackets = 0x%x\n",__FUNCTION__,__LINE__, eth3_pm_new->underPackets);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->fragments = 0x%x\n",__FUNCTION__,__LINE__, eth3_pm_new->fragments);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->jabbers = 0x%x\n",__FUNCTION__,__LINE__, eth3_pm_new->jabbers);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->packets64 = 0x%x\n",__FUNCTION__,__LINE__, eth3_pm_new->packets64);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->packets65to127 = 0x%x\n",__FUNCTION__,__LINE__, eth3_pm_new->packets65to127);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->packets128to255 = 0x%x\n",__FUNCTION__,__LINE__, eth3_pm_new->packets128to255);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->packets256to511 = 0x%x\n",__FUNCTION__,__LINE__, eth3_pm_new->packets256to511);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->packets512to1023 = 0x%x\n",__FUNCTION__,__LINE__, eth3_pm_new->packets512to1023);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->packets1024to1518 = 0x%x\n",__FUNCTION__,__LINE__, eth3_pm_new->packets1024to1518);
	

    return 0;
}

int omci_me_eth3_pm_history_notify(pm_history_data_list_ptr pm_list, omci_me_info_t threshold_info)
{
    enum{ ETH3_PM_HISTORY_DATA_TCA_NUM = 4};
    omci_threshold_data_1_ptr threshold_data1 = NULL;
    int i = 0;
    uint32_t currentData[ETH3_PM_HISTORY_DATA_TCA_NUM] = {0};
    static uint8_t reportFlag[ETH3_PM_HISTORY_DATA_TCA_NUM] = {0};
    uint8_t alarm_num[ETH3_PM_HISTORY_DATA_TCA_NUM] = {0, 1, 2, 3};
    tca_notify_info_t tca_info = {0};
    PPTPEthernetUNI3Pmcounters_t pptpEth3Uni ={0};

    if(pm_list == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  pm_list is NULL fail\n",__FUNCTION__,__LINE__);
        return -1;
    }
    if(omci_pm_is_end_of_interval_time())
    {
        memset(reportFlag, 0, sizeof(reportFlag));
        return 0;
    }
    if(threshold_info.class_id != OMCI_CLASS_ID_THRESHOLD_DATA1){
        return 0;
    }
    
    
	threshold_data1 =  (omci_threshold_data_1_ptr)threshold_info.attributes;
    if(threshold_data1 == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  threshold value is NULL \n",__FUNCTION__,__LINE__);
        return -1;
    }
    if(get_pptp_eth3_uni_data(&pptpEth3Uni, pm_list->instId) != 0) {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  get_pptp_eth_uni_data fail\n",__FUNCTION__,__LINE__);
        return -1;
    }
    /*monitor 15min interval tca attribute value*/
    currentData[0] = pptpEth3Uni.dropEvents - pm_list->pm_prev_data.pptpEth3Uni.dropEvents;
    currentData[1] = pptpEth3Uni.undersizePkts - pm_list->pm_prev_data.pptpEth3Uni.undersizePkts;
    currentData[2] = pptpEth3Uni.fragments - pm_list->pm_prev_data.pptpEth3Uni.fragments;
    currentData[3] = pptpEth3Uni.jabbers - pm_list->pm_prev_data.pptpEth3Uni.jabbers;
    for(i = 0; i < ETH3_PM_HISTORY_DATA_TCA_NUM; i++)
    {
        tca_info.classId = pm_list->classId;
        tca_info.instId = pm_list->instId;
        tca_info.currentData = currentData[i];
        tca_info.threshold = threshold_data1->thresholdValue[i];
        tca_info.alarm_num = alarm_num[i];
        tca_info.reportFlag = reportFlag[i];

        reportFlag[i] = omci_pm_report_alarm_by_tca_info(tca_info, 0);
	}

	return 0;
    
}

omci_me_func_t omci_me_eth_pm_his_3_op ={
	omci_me_general_pm_history_create_del_op,
	omci_me_general_pm_history_create_del_op,
	omci_me_general_pm_history_set_op,
	omci_me_general_pm_history_get_op,
	omci_me_eth3_pm_history_get_curr_op,
};

omci_eth_pm_his_3_t omci_eth_pm_his_3_attr_data = {0};

omci_attr_t omci_eth_pm_his_3_attr ={
	(uint8_t *)&omci_eth_pm_his_3_attr_data,
	sizeof(omci_eth_pm_his_3_attr_data)
};

/*******************************************************************************************************************************
9.5.6 Ethernet performance monitoring history data 4

********************************************************************************************************************************/
omci_attr_dscp_t omci_attr_eth_pm_his_4_op[]={
{0, "meId", 					        2,	ATTR_ACCESS_R_SET_CREATE,		ATTR_FORMAT_UNSIGNED_INT,	ATTR_FULLY_SUPPORT,	&generalAttrFunc},
{1, "interval end time",				1,	ATTR_ACCESS_R,					ATTR_FORMAT_UNSIGNED_INT,	ATTR_FULLY_SUPPORT, &generalAttrFunc},
{2, "threshold data 1/2 id",			2,	ATTR_ACCESS_R_W_SET_CREATE,     ATTR_FORMAT_UNSIGNED_INT,	ATTR_FULLY_SUPPORT, &generalAttrFunc},
{3, "Association type",					1,	ATTR_ACCESS_R_W_SET_CREATE,	    ATTR_FORMAT_UNSIGNED_INT,	ATTR_FULLY_SUPPORT, &generalAttrFunc},
{4, "Transmitted traffic",				4,	ATTR_ACCESS_R,					ATTR_FORMAT_UNSIGNED_INT,	ATTR_FULLY_SUPPORT, &generalAttrFunc},
{5, "Received traffic",					4,	ATTR_ACCESS_R,					ATTR_FORMAT_UNSIGNED_INT,	ATTR_FULLY_SUPPORT, &generalAttrFunc},
{6, "Transmitted rate",				    4,	ATTR_ACCESS_R,					ATTR_FORMAT_UNSIGNED_INT,	ATTR_FULLY_SUPPORT, &generalAttrFunc},
{7, "Received rate",					4,	ATTR_ACCESS_R,					ATTR_FORMAT_UNSIGNED_INT,	ATTR_FULLY_SUPPORT, &generalAttrFunc},
{8, "Transmitted Octets",			    4,	ATTR_ACCESS_R,					ATTR_FORMAT_UNSIGNED_INT,	ATTR_FULLY_SUPPORT, &generalAttrFunc},
{9, "Received Octets",					4,	ATTR_ACCESS_R,					ATTR_FORMAT_UNSIGNED_INT,	ATTR_FULLY_SUPPORT, &generalAttrFunc},
{10, "Transmitted discard counter", 	4,	ATTR_ACCESS_R,					ATTR_FORMAT_UNSIGNED_INT,	ATTR_FULLY_SUPPORT, &generalAttrFunc},
{11, "Received discard counter",		4,	ATTR_ACCESS_R,					ATTR_FORMAT_UNSIGNED_INT,	ATTR_FULLY_SUPPORT, &generalAttrFunc},
{12, "Transmitted error counter",		4,	ATTR_ACCESS_R,					ATTR_FORMAT_UNSIGNED_INT,	ATTR_FULLY_SUPPORT, &generalAttrFunc},
{13, "Received error counter",	        4,	ATTR_ACCESS_R,					ATTR_FORMAT_UNSIGNED_INT,	ATTR_FULLY_SUPPORT, &generalAttrFunc},
{255, "", 0, 0,  0, 0, NULL}
};

int get_eth4_pm_history_data(PPTPEthernetUNI4Pmcounters_t *data, uint16_t instId)
{
	uint8_t associationType = (instId & 0x8000) >> 15;//if ani,instid is 0x8001/If uni,instid is0x101~0x014
	uint32_t cnt = 0;
	uint8_t validPortId = 0;

	if(data == NULL)
	{
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]pointer is NULL.\n",__FUNCTION__,__LINE__);
		return -1;
	}

	memset(data, 0, sizeof(PPTPEthernetUNI4Pmcounters_t));
	validPortId = (instId & 0xff) - 1;
	
	/*gdm_sel :lan or wan;*/
	if(associationType == ETHERNET_PM4_BIT_PPTP)//multi port,here is lan part
	{
		
		if(blapi_traffic_get_lan_tx_traffic(validPortId,&cnt) == 0)//The instId should be 0,1,2,3
		{
			data->transmitted_traffic = cnt;
		}
		if(blapi_traffic_get_lan_rx_traffic(validPortId,&cnt) == 0)
		{
			data->received_traffic = cnt;
		}
		if(blapi_traffic_get_lan_tx_rate(validPortId,&cnt) == 0)
		{
			data->transmitted_rate= cnt;
		}
		if(blapi_traffic_get_lan_rx_rate(validPortId,&cnt) == 0)
		{
			data->received_rate= cnt;
		}
		if(blapi_traffic_get_lan_tx_octets(validPortId,&cnt) == 0)
		{
			data->transmitted_Octets= cnt;
		}
		if(blapi_traffic_get_lan_rx_octets(validPortId,&cnt) == 0)
		{
			data->received_Octets= cnt;
		}
		if(blapi_traffic_get_lan_rx_discard_counter(validPortId,&cnt) == 0)
		{
			data->received_dis_cout= cnt;
		}
		if(blapi_traffic_get_lan_tx_discard_counter(validPortId,&cnt) == 0)
		{
			data->transmitted_dis_cout= cnt;
		}
		if(blapi_traffic_get_lan_rx_error_counter(validPortId,&cnt) == 0)
		{
			data->received_err_cout= cnt;
		}
		if(blapi_traffic_get_lan_tx_error_counter(validPortId,&cnt) == 0)
		{
			data->transmitted_err_cout= cnt;
		}
		
	}
	else if(associationType == ETHERNET_PM4_BIT_GEMPort)//just one port,here is wan part,no "portid" concept,just 0 
	{
		if(blapi_traffic_get_wan_tx_traffic(&cnt) == 0)
		{
			data->transmitted_traffic = cnt;
		}
		if(blapi_traffic_get_wan_rx_traffic(&cnt) == 0)
		{
			data->received_traffic = cnt;
		}
		if(blapi_traffic_get_wan_tx_rate(&cnt) == 0)
		{
			data->transmitted_rate= cnt;
		}
		if(blapi_traffic_get_wan_rx_rate(&cnt) == 0)
		{
			data->received_rate= cnt;
		}
		if(blapi_traffic_get_wan_tx_octets(&cnt) == 0)
		{
			data->transmitted_Octets= cnt;
		}
		if(blapi_traffic_get_wan_rx_octets(&cnt) == 0)
		{
			data->received_Octets= cnt;
		}
		if(blapi_traffic_get_wan_rx_discard_counter(&cnt) == 0)
		{
			data->received_dis_cout= cnt;
		}
		if(blapi_traffic_get_wan_tx_discard_counter(&cnt) == 0)
		{
			data->transmitted_dis_cout= cnt;
		}
		if(blapi_traffic_get_wan_rx_error_counter(&cnt) == 0)
		{
			data->received_err_cout= cnt;
		}
		if(blapi_traffic_get_wan_tx_error_counter(&cnt) == 0)
		{
			data->transmitted_err_cout= cnt;
		}
	}
	else
	{
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  direction Error\n",__FUNCTION__,__LINE__);
	}
	
	return 0;
}

int omci_me_eth4_pm_history_get_curr_op(management_entry_ptr me_entry, omci_me_info_ptr me_info)
{
	omci_eth_pm_his_4_ptr eth4_pm_new = NULL;
	PPTPEthernetUNI4Pmcounters_t Eth4PmData ={0};

	if(me_entry == NULL || me_info == NULL)
	{
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]pointer is NULL.\n",__FUNCTION__,__LINE__);
		return -1;
	}

	eth4_pm_new = (omci_eth_pm_his_4_ptr)me_info->attributes;
	if(eth4_pm_new == NULL)
	{
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]me info attribute is NULL.\n",__FUNCTION__,__LINE__);
		return -1;
	}
	if(get_eth4_pm_history_data(&Eth4PmData, me_info->inst_id) != 0) {
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  get_pptp_eth_uni_data fail\n",__FUNCTION__,__LINE__);
		return -1;
	}

	eth4_pm_new->interEndTime= pmIntervalTimes;
	eth4_pm_new->transmitted_traffic= Eth4PmData.transmitted_traffic;
	eth4_pm_new->received_traffic= Eth4PmData.received_traffic;
	eth4_pm_new->transmitted_rate= Eth4PmData.transmitted_rate;
	eth4_pm_new->received_rate= Eth4PmData.received_rate;
	eth4_pm_new->transmitted_Octets= Eth4PmData.transmitted_Octets;
	eth4_pm_new->received_Octets= Eth4PmData.received_Octets;
	eth4_pm_new->transmitted_dis_cout= Eth4PmData.transmitted_dis_cout;
	eth4_pm_new->received_dis_cout= Eth4PmData.received_dis_cout;
	eth4_pm_new->transmitted_err_cout= Eth4PmData.transmitted_err_cout;
	eth4_pm_new->received_err_cout= Eth4PmData.received_err_cout;


	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->transmitted_traffic = 0x%x\n",__FUNCTION__,__LINE__, eth4_pm_new->transmitted_traffic);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->received_traffic = 0x%x\n",__FUNCTION__,__LINE__, eth4_pm_new->received_traffic);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->transmitted_rate = 0x%x\n",__FUNCTION__,__LINE__, eth4_pm_new->transmitted_rate);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->received_rate = 0x%x\n",__FUNCTION__,__LINE__, eth4_pm_new->received_rate);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->transmitted_Octets = 0x%x\n",__FUNCTION__,__LINE__, eth4_pm_new->transmitted_Octets);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->received_Octets = 0x%x\n",__FUNCTION__,__LINE__, eth4_pm_new->received_Octets);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->transmitted_dis_cout = 0x%x\n",__FUNCTION__,__LINE__, eth4_pm_new->transmitted_dis_cout);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->received_dis_cout = 0x%x\n",__FUNCTION__,__LINE__, eth4_pm_new->received_dis_cout);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->transmitted_err_cout = 0x%x\n",__FUNCTION__,__LINE__, eth4_pm_new->transmitted_err_cout);
	omcidbgPrintf(OMCI_DEBUG_LEVEL_DEBUG,"[%s][%d]->received_err_cout = 0x%x\n",__FUNCTION__,__LINE__, eth4_pm_new->received_err_cout);
	
	return 0;
}
omci_me_func_t omci_me_eth_pm_his_4_op ={
	omci_me_general_pm_history_create_del_op,
	omci_me_general_pm_history_create_del_op,
	omci_me_general_pm_history_set_op,
	omci_me_general_pm_history_get_op,
	omci_me_eth4_pm_history_get_curr_op,
};

omci_eth_pm_his_4_t omci_eth_pm_his_4_attr_data = {0};

omci_attr_t omci_eth_pm_his_4_attr ={
	(uint8_t *)&omci_eth_pm_his_4_attr_data,
	sizeof(omci_eth_pm_his_4_attr_data)
};
/*******************************************************************************************************************************
9.5.5 Virtual Ethernet interface point

********************************************************************************************************************************/

static attribute_func_t virtualEthernetInterfacePointAdminStateFunc = {
	NULL,
	setVirtualEthernetInterfacePointAdminStateValue
};

static attribute_func_t virtualEthernetInterfacePointOpStateFunc = {
	getVirtualEthernetInterfacePointOpStateValue,
	NULL
};

static attribute_func_t virtualEthernetInterfacePointInterDomainFunc = {
	NULL,
	setVirtualEthernetInterfacePointInterDomain,
};
static attribute_func_t virtualEthernetInterfacePointIANAAssignedPortFunc = {
	getVirtualEthernetInterfacePointIANAAssignedPortValue,
	NULL
};

omci_attr_dscp_t omci_attr_veip_op[]={
{0, "meId",					2,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,&generalAttrFunc},
{1, "admin state",			1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_ENUM,            ATTR_FULLY_SUPPORT,&virtualEthernetInterfacePointAdminStateFunc},
{2, "operational state",	1,  ATTR_ACCESS_R,      ATTR_FORMAT_ENUM,            ATTR_FULLY_SUPPORT,&virtualEthernetInterfacePointOpStateFunc},
{3, "interdomain name", 	25, ATTR_ACCESS_R_W,    ATTR_FORMAT_STRING,          ATTR_FULLY_SUPPORT,&virtualEthernetInterfacePointInterDomainFunc},
{4, "tcp/udp pointer",		2,  ATTR_ACCESS_R_W,    ATTR_FORMAT_POINTER,         ATTR_FULLY_SUPPORT,&generalAttrFunc},
{5, "iana assigned port",	2,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,&virtualEthernetInterfacePointIANAAssignedPortFunc},
{255, "", 					0,  0, 0, 0, 	NULL}
};
omci_me_func_t omci_me_veip_op ={
	omci_me_general_create_op,
	omci_me_general_delete_op,
	omci_me_general_set_op,
	omci_me_general_get_op,
};

omci_veip_t omci_veip_attr_data = {0};

omci_attr_t omci_veip_attr ={
	(uint8_t *)&omci_veip_attr_data,
	sizeof(omci_veip_attr_data)
};

/*******************************************************************************************************************************
9.5.1 PPTP Ethernet UNI

********************************************************************************************************************************/

#define EN8811_MODE_FIX_100M      0
#define EN8811_MODE_FIX_1G        1
#define EN8811_MODE_FIX_2500M     2
#define EN8811_MODE_AUTO          3

uint8_t convertEn8811ModeToAutoDetectConfig(uint8_t mode)
{
	switch(mode)
	{
		case EN8811_MODE_FIX_100M:
			return 2;
		case EN8811_MODE_FIX_1G:
			return 3;
		case EN8811_MODE_FIX_2500M:
			return 6;
		case EN8811_MODE_AUTO:
			return 0;
		default:
			return 0;
	}
}

uint8_t convertAutoDetectConfigToEn8811Mode(uint8_t cfg)
{
	switch(cfg)
	{
		case 2:
			return EN8811_MODE_FIX_100M;
		case 3:
			return EN8811_MODE_FIX_1G;
		case 6:
			return EN8811_MODE_FIX_2500M;
		case 0:
			return EN8811_MODE_AUTO;
		default:
			return EN8811_MODE_AUTO;
	}
}

int getPPTPEthernetUNIAutoDetectConfig(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr)
{	
	int portId = 0;
	int ret = 0;
	uint8_t mode = 0;
	omci_pptp_eth_uni_ptr pptp_eth_uni_attr = NULL;

	omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d]:Enter!\n",__FUNCTION__,__LINE__);
    if(NULL == me_info  || NULL == omci_attr){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, " [%s][%d] parameter is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	pptp_eth_uni_attr = (omci_pptp_eth_uni_ptr)me_info->attributes;
    if(pptp_eth_uni_attr == NULL ){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  attributes is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	
	portId = getPortIdxByInstId(me_info->inst_id);
	if(portId <= 0) { 
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"[%s][%d]:  portId error\n",__FUNCTION__,__LINE__);
		ret = -1;
		goto end;
	}
	portId--;
	if(pSystemCap->ethType[portId] == UNIT_TYPE_BASET_10100 ||pSystemCap->ethType[portId] == UNIT_TYPE_BASET_101001000 ) {
		//api
		ret = switchmgr_lib_get_port_autodetection(portId,&mode);
		if(ret == -1){
			omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"\r\n getPPTPEthernetUNIAutoDetectConfig->macMT7530GetAutoDetection fail[%d]",__LINE__);		
			goto end;
		}
	}
	else if(pSystemCap->ethType[portId] == UNIT_TYPE_ETHER_2500) {
		/*ret = blapi_traffic_get_en8811_mode();
		if(ret < 0){
			omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"\r\n setPPTPEthernetUNIAutoDetectConfig->blapi_traffic_get_en8811_mode fail[%d]",__LINE__);		
			goto end;
		}
		mode = convertEn8811ModeToAutoDetectConfig(ret);*/
	}
	else if(pSystemCap->ethType[portId] == UNIT_TYPE_ETHER_10G) {
		;                                    //to be implemented
	}
	pptp_eth_uni_attr->autoDetectionCfg = mode;

	if(bbf247_enable)
	{ 
		/*BBF247 issue4 TC_6.9.4.js use Auto mode*/
		pptp_eth_uni_attr->autoDetectionCfg = 0; 
	}
	
	ret = 0;
end:	
	return ret;
}


int setPPTPEthernetUNIAutoDetectConfig(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr)
{
	int portId = 0;
	int ret = 0;
	uint8_t mode = 0;
	uint8_t oldMode = 0;
	omci_pptp_eth_uni_ptr pptp_eth_uni_attr = NULL;
	omci_me_info_t old_me_info = {0};
	omci_pptp_eth_uni_ptr old_pptp_eth_uni_attr = NULL;
	
	omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d]:Enter\n",__FUNCTION__,__LINE__);
    if(NULL == me_info || NULL == omci_attr){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  parameter is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
	}
	pptp_eth_uni_attr = (omci_pptp_eth_uni_ptr)me_info->attributes;
	if(pptp_eth_uni_attr == NULL ){
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  attributes is NULL, fail\n",__FUNCTION__,__LINE__);
		ret = -1;
		goto end;
	}

	portId = getPortIdxByInstId(me_info->inst_id);
	if(portId <= 0) { 
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"[%s][%d]:  portId error\n",__FUNCTION__,__LINE__);
		ret = -1;
		goto end;
	}
	portId--;
	mode = pptp_eth_uni_attr->autoDetectionCfg;

	old_me_info.class_id = me_info->class_id;
	old_me_info.inst_id = me_info->inst_id;
	if(omci_attr_get_old_data_except_table_attr(&old_me_info) != 0){
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]get data failed.\n",__FUNCTION__,__LINE__);
		ret = -1;
		goto end;
	}
	old_pptp_eth_uni_attr = (omci_pptp_eth_uni_ptr)old_me_info.attributes;
	if(NULL == old_pptp_eth_uni_attr){
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "%s->old_pptp_eth_uni_attr calloc fail\n",__FUNCTION__);
		ret = -1;
		goto end;
	}
	oldMode = old_pptp_eth_uni_attr->autoDetectionCfg;

	omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE,"\r\n setPPTPEthernetUNIPauseTime->oldMode = %d, mode = %d, [%d]",oldMode, mode, __LINE__);	
	if (oldMode != mode)
	{
		if(pSystemCap->ethType[portId] == UNIT_TYPE_BASET_10100 ||pSystemCap->ethType[portId] == UNIT_TYPE_BASET_101001000 ) {
			//api
			ret = switchmgr_lib_set_port_autodetection(portId, mode);
			if(ret == -1){
				omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"\r\n setPPTPEthernetUNIAutoDetectConfig->macMT7530SetAutoDetection fail[%d]",__LINE__);		
				goto end;
			}	
		}
		else if(pSystemCap->ethType[portId] == UNIT_TYPE_ETHER_2500) {
			/*ret = blapi_traffic_set_en8811_mode(convertAutoDetectConfigToEn8811Mode(mode));
			if(ret == -1){
				omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"\r\n setPPTPEthernetUNIAutoDetectConfig->blapi_traffic_set_en8811_mode fail[%d]",__LINE__);		
				goto end;
			}*/
		}
		else if(pSystemCap->ethType[portId] == UNIT_TYPE_ETHER_10G) {
			;                                    //to be implemented
		}	
	}
	ret = 0;
end:	
	return ret;
	
}

int getPPTPEthernetUNIEthernetLoopbackCfg(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr)
{
	int portId = 0;
	int ret = 0;
	uint8_t mode = 0;
	omci_pptp_eth_uni_ptr pptp_eth_uni_attr = NULL;

	omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d]:Enter\n",__FUNCTION__,__LINE__);
    if(NULL == me_info  || NULL == omci_attr){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  parameter is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	pptp_eth_uni_attr = (omci_pptp_eth_uni_ptr)me_info->attributes;
    if(pptp_eth_uni_attr == NULL ){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  attributes is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	
	portId = getPortIdxByInstId(me_info->inst_id);
	if(portId <= 0) { 
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"[%s][%d]:  portId error\n",__FUNCTION__,__LINE__);
		ret = -1;
		goto end;
	}
	portId--;
	if(pSystemCap->ethType[portId] == UNIT_TYPE_BASET_10100 ||pSystemCap->ethType[portId] == UNIT_TYPE_BASET_101001000 ) {
		//api
		ret = switchmgr_lib_get_port_loopback(portId,&mode);
		if(ret == -1){
			omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"\r\n getPPTPEthernetUNIEthernetLoopbackCfg->macMT7530GetLoopbackConf fail[%d]",__LINE__);		
	        goto end;
		}
		pptp_eth_uni_attr->ethernetLoopbackCfg = mode;
		ret = 0;
	}
	else if(pSystemCap->ethType[portId] == UNIT_TYPE_ETHER_2500) {
		;                                    //to be implemented
	}
	else if(pSystemCap->ethType[portId] == UNIT_TYPE_ETHER_10G) {
		;                                    //to be implemented
	}	
		
end:	
	return ret;
}

int setPPTPEthernetUNIEthernetLoopbackCfg(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr)
{
	int portId = 0;
	int ret = 0;
	uint8_t tmpValue = 0;
	omci_pptp_eth_uni_ptr pptp_eth_uni_attr = NULL;

	omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d]:Enter\n",__FUNCTION__,__LINE__);
    if(NULL == me_info  || NULL == omci_attr){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  parameter is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	pptp_eth_uni_attr = (omci_pptp_eth_uni_ptr)me_info->attributes;
    if(pptp_eth_uni_attr == NULL ){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  attributes is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	
	portId = getPortIdxByInstId(me_info->inst_id);
	if(portId <= 0) {   
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"[%s][%d]:  portId error\n",__FUNCTION__,__LINE__);
		ret = -1;
		goto end;
	}
	portId--;
	tmpValue = pptp_eth_uni_attr->ethernetLoopbackCfg;
	
	if((tmpValue != 0x0)
		&& (tmpValue != 0x3)){
		omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE,"\r\n setPPTPEthernetUNIEthernetLoopbackCfg para error, tmpValue=0x%02x",tmpValue);
		return -1;
	}
	//api
	if(tmpValue == 0x0){
		if(pSystemCap->ethType[portId] == UNIT_TYPE_BASET_10100 ||pSystemCap->ethType[portId] == UNIT_TYPE_BASET_101001000 ) {
			//api
			ret = switchmgr_lib_set_port_loopback(portId, 0);
#if/*TCSUPPORT_COMPILE*/ defined(TCSUPPORT_ALPHION_PON) && defined(TCSUPPORT_CT_LOOPDETECT)
        	setPortLoopDetect(portId,1);
#endif/*TCSUPPORT_COMPILE*/
		}
		else if(pSystemCap->ethType[portId] == UNIT_TYPE_ETHER_2500) {
			;                                    //to be implemented
		}
		else if(pSystemCap->ethType[portId] == UNIT_TYPE_ETHER_10G) {
			;                                    //to be implemented
		}	
	}else if(tmpValue == 0x3){
		if(pSystemCap->ethType[portId] == UNIT_TYPE_BASET_10100 ||pSystemCap->ethType[portId] == UNIT_TYPE_BASET_101001000 ) {
			ret = switchmgr_lib_set_port_loopback(portId, 1);
#if/*TCSUPPORT_COMPILE*/ defined(TCSUPPORT_ALPHION_PON) && defined(TCSUPPORT_CT_LOOPDETECT)
        	setPortLoopDetect(portId,0);
#endif/*TCSUPPORT_COMPILE*/
		}
		else if(pSystemCap->ethType[portId] == UNIT_TYPE_ETHER_2500) {
			;                                    //to be implemented
		}
		else if(pSystemCap->ethType[portId] == UNIT_TYPE_ETHER_10G) {
			;                                    //to be implemented
		}	
	}
	if(ret == -1){
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"\r\n setPPTPEthernetUNIEthernetLoopbackCfg->macMT7530SetLoopbackConf fail[%d]",__LINE__);		
        goto end;
	}	
	ret = 0;

end:	
	return ret;
}


int setPPTPEthernetUNIAdminStateValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr)
{
	int portId = 0;
	uint8_t oldValue = 0;
	uint8_t tmpValue = 0;
	int ret = 0;
	omci_pptp_eth_uni_ptr pptp_eth_uni_attr = NULL;
	omci_me_info_t old_me_info = {0};
	omci_pptp_eth_uni_ptr old_pptp_eth_uni_attr = NULL;

	omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d]:Enter\n",__FUNCTION__,__LINE__);
    if(NULL == me_info  || NULL == omci_attr){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  parameter is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	pptp_eth_uni_attr = (omci_pptp_eth_uni_ptr)me_info->attributes;
    if(pptp_eth_uni_attr == NULL ){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  attributes is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	
	portId = getPortIdxByInstId(me_info->inst_id);
	if(portId <= 0) {  
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"[%s][%d]:  portId error\n",__FUNCTION__,__LINE__);
		ret = -1;
		goto end;
	}
	portId--;
	tmpValue = pptp_eth_uni_attr->adminState;

	old_me_info.class_id = me_info->class_id;
	old_me_info.inst_id = me_info->inst_id;
	if(omci_attr_get_old_data_except_table_attr(&old_me_info) != 0){
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]get data failed.\n",__FUNCTION__,__LINE__);
		ret = -1;
		goto end;
	}
	old_pptp_eth_uni_attr = (omci_pptp_eth_uni_ptr)old_me_info.attributes;
	if(NULL == old_pptp_eth_uni_attr){
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "%s->old_pptp_eth_uni_attr calloc fail\n",__FUNCTION__);
		ret = -1;
		goto end;
	}
	oldValue = old_pptp_eth_uni_attr->adminState;
	
	omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE,"[%s][%d]->oldValue = %d, tmpValue = %d\n",__FUNCTION__,__LINE__,oldValue, tmpValue);	
	/*deal with op state AVC, if admin state changes, we should send op state AVC*/
	if(tmpValue != oldValue){
		if(pSystemCap->ethType[portId] == UNIT_TYPE_BASET_10100 ||pSystemCap->ethType[portId] == UNIT_TYPE_BASET_101001000 ) {
			omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE,"[%s][%d]: --------portId=%d------\n",__FUNCTION__,__LINE__,portId);	
			ret = macMT7530SetPortAdmin(tmpValue, portId);
			omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE,"[%s][%d]: --------ret=%d------\n",__FUNCTION__,__LINE__,ret);	
			if(ret == -1){
				omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"\r\n setPPTPEthernetUNIAdminStateValue->macMT7530SetPortAdmin fail[%d]",__LINE__);	
				goto end;
			}
		}
		else if(pSystemCap->ethType[portId] == UNIT_TYPE_ETHER_2500) {
			;                                    //to be implemented
		}
		else if(pSystemCap->ethType[portId] == UNIT_TYPE_ETHER_10G) {
			;                                    //to be implemented
		}	
	}
	ret = 0;
end:	
	return ret;

}

int link_rate_to_configuration_ind(char *link_rate, u8 *mode)
{	
	if (strcmp(link_rate, "10M/Full") == 0)
		*mode = 0x1;
	else if (strcmp(link_rate, "100M/Full") == 0)
		*mode = 0x2;
	else if (strcmp(link_rate, "1000M/Full") == 0)
		*mode = 0x3;
	else if (strcmp(link_rate, "10G/Full") == 0)
		*mode = 0x4;
	else if (strcmp(link_rate, "2.5G/Full") == 0)
		*mode = 0x5;
	else if (strcmp(link_rate, "5G/Full") == 0)
		*mode = 0x6;
	else if (strcmp(link_rate, "25G/Full") == 0)
		*mode = 0x7;
	else if (strcmp(link_rate, "40G/Full") == 0)
		*mode = 0x8;
	else if (strcmp(link_rate, "10M/Half") == 0)
		*mode = 0x11;
	else if (strcmp(link_rate, "100M/Half") == 0)
		*mode = 0x12;
	else if (strcmp(link_rate, "1000M/Half") == 0)
		*mode = 0x13;
	else 
		return -1;
	
	return 0;
}

int getPPTPEthernetUNICfgIndValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr)
{
	int portId = 0;
	int ret = 0;
	uint8_t mode = 0;
	omci_pptp_eth_uni_ptr pptp_eth_uni_attr = NULL;
	lanport_info_t lanport_info;

	omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d]:Enter\n",__FUNCTION__,__LINE__);
    if(NULL == me_info  || NULL == omci_attr){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  parameter is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	pptp_eth_uni_attr = (omci_pptp_eth_uni_ptr)me_info->attributes;
    if(pptp_eth_uni_attr == NULL ){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  attributes is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	
	portId = getPortIdxByInstId(me_info->inst_id);
	if(portId <= 0 || portId > LANPORT_INFO_MAX_PORT) {                  //in definition of lanport_info, max port num is 8 
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"[%s][%d]:  portId error\n",__FUNCTION__,__LINE__);
		ret = -1;
		goto end;
	}
	portId = xsi_lanport_info_covert(portId);
	portId--;
	//api
	ret = blapi_traffic_get_lanport_info(&lanport_info);
	if(ret == -1){
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"\r\n getPPTPEthernetUNICfgIndValue->blapi_traffic_get_lanport_info fail[%d]",__LINE__);		
		goto end;
	}
	omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d]:lan_port = %s, link_rate = %s\n",__FUNCTION__,__LINE__,lanport_info.lan_port[portId],lanport_info.link_rate[portId]);

	if(strcmp(lanport_info.lan_status[portId], "UP") == 0) {
		ret = link_rate_to_configuration_ind(lanport_info.link_rate[portId],&mode);
		if(ret == -1){
			omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"\r\n getPPTPEthernetUNICfgIndValue->link_rate_to_mode fail[%d]",__LINE__);		
			goto end;
		}
	}
	
	pptp_eth_uni_attr->cfgInd= mode;
	ret = 0;

end:	
	return ret;
}


int getPPTPEthernetUNIMaxFrameSize(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr)
{
	int portId = 0;
	int ret = 0;
	uint16_t maxFrameSize = 0;
	omci_pptp_eth_uni_ptr pptp_eth_uni_attr = NULL;

	omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d]:Enter\n",__FUNCTION__,__LINE__);
    if(NULL == me_info  || NULL == omci_attr){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  parameter is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	pptp_eth_uni_attr = (omci_pptp_eth_uni_ptr)me_info->attributes;
    if(pptp_eth_uni_attr == NULL ){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  attributes is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	
	portId = getPortIdxByInstId(me_info->inst_id);
	if(portId <= 0) { 
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"[%s][%d]:  portId error\n",__FUNCTION__,__LINE__);
		ret = -1;
		goto end;
	}
	portId--;
	if(pSystemCap->ethType[portId] == UNIT_TYPE_BASET_10100 ||pSystemCap->ethType[portId] == UNIT_TYPE_BASET_101001000 ) {
		//api
		ret = macMT7530GetMaxFrameSize(&maxFrameSize, portId);
		if(ret == -1){
			omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"\r\n getPPTPEthernetUNIMaxFrameSize->macMT7530GetMaxFrameSize fail[%d]",__LINE__); 	
	        goto end;
		}
		pptp_eth_uni_attr->maxFrameSize = maxFrameSize;
		ret = 0;
	}
	else if(pSystemCap->ethType[portId] == UNIT_TYPE_ETHER_2500) {
		;                                    //to be implemented
	}
	else if(pSystemCap->ethType[portId] == UNIT_TYPE_ETHER_10G) {
		;                                    //to be implemented
	}	
	
end:	
	if(bbf247_enable)
	{
		return 0;
	}
	else
	{
		return ret;
	}
}


int setPPTPEthernetUNIMaxFrameSize(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr)
{
	int portId = 0;
	uint16_t maxFrameSize = 0;
	omci_pptp_eth_uni_ptr pptp_eth_uni_attr = NULL;

	omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d]:Enter\n",__FUNCTION__,__LINE__);
    if(NULL == me_info  || NULL == omci_attr){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  parameter is NULL, fail\n",__FUNCTION__,__LINE__);
        return -1;
    }
	pptp_eth_uni_attr = (omci_pptp_eth_uni_ptr)me_info->attributes;
    if(pptp_eth_uni_attr == NULL ){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  attributes is NULL, fail\n",__FUNCTION__,__LINE__);
        return -1;
    }
	
	portId = getPortIdxByInstId(pptp_eth_uni_attr->meId);
	if(portId <= 0) { 
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"[%s][%d]:  portId error\n",__FUNCTION__,__LINE__);
		return -1;
	}
	portId--;
	maxFrameSize = pptp_eth_uni_attr->maxFrameSize;
	omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d]:  portId =%d, maxFrameSize = %d\n",__FUNCTION__,__LINE__,portId,maxFrameSize);
	
#if/*TCSUPPORT_COMPILE*/ defined(TCSUPPORT_CHS)
	if(maxFrameSize > 2000 || maxFrameSize < 64) {
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"[%s][%d]: maxFrameSize=%d, exceeding the scope 64--2000",__FUNCTION__,__LINE__,maxFrameSize); 
		return -1;
	}
	//api

	char cmdbuffer[256] = {0};	
	sprintf(cmdbuffer, "echo %d > /proc/tc3162/gsw_mtu", maxFrameSize);
	system(cmdbuffer);	
	sprintf(cmdbuffer, "/userfs/bin/hw_nat -!");
	system(cmdbuffer);
#else/*TCSUPPORT_COMPILE*/
	if(pSystemCap->ethType[portId] == UNIT_TYPE_BASET_10100 ||pSystemCap->ethType[portId] == UNIT_TYPE_BASET_101001000 ) {
		/* NOTE: maxFrameSize 2000 will set fail, but  this result do not return (follow legacy behavior )*/
		if(macMT7530SetMaxFrameSize(maxFrameSize, portId) == -1){
			omcidbgPrintf(OMCI_DEBUG_LEVEL_WARN,"[%s][%d]:macMT7530SetMaxFrameSize fail, maxFrameSize=%d,portId=%d\n",__FUNCTION__,__LINE__,maxFrameSize,portId); 
		}
	}
	else if(pSystemCap->ethType[portId] == UNIT_TYPE_ETHER_2500) {
		;                                    //to be implemented
	}
	else if(pSystemCap->ethType[portId] == UNIT_TYPE_ETHER_10G) {
		;                                    //to be implemented
	}	

#endif/*TCSUPPORT_COMPILE*/

	return 0;
}

int getPPTPEthernetUNIPauseTime(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr)
{
	int portId = 0;
	int ret = 0;
	uint16_t pauseTime = 0;
	omci_pptp_eth_uni_ptr pptp_eth_uni_attr = NULL;

	omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d]:Enter\n",__FUNCTION__,__LINE__);
    if(NULL == me_info  || NULL == omci_attr){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  parameter is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	pptp_eth_uni_attr = (omci_pptp_eth_uni_ptr)me_info->attributes;
    if(pptp_eth_uni_attr == NULL ){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  attributes is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	
	portId = getPortIdxByInstId(me_info->inst_id);
	if(portId <= 0) { 
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"[%s][%d]:  portId error\n",__FUNCTION__,__LINE__);
		ret = -1;
		goto end;
	}
	portId--;
	if(pSystemCap->ethType[portId] == UNIT_TYPE_BASET_10100 ||pSystemCap->ethType[portId] == UNIT_TYPE_BASET_101001000 ) {
		//api
		ret = macMT7530GetPauseTime(&pauseTime, portId);
		if(ret == -1){
			omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"\r\n getPPTPEthernetUNIPauseTime->macMT7530GetPauseTime fail[%d]",__LINE__);	
	        goto end;
		}
		pptp_eth_uni_attr->pauseTime = pauseTime;
		ret = 0;
	}
	else if(pSystemCap->ethType[portId] == UNIT_TYPE_ETHER_2500) {
		;                                    //to be implemented
	}
	else if(pSystemCap->ethType[portId] == UNIT_TYPE_ETHER_10G) {
		;                                    //to be implemented
	}	
	
end:	
	return ret;
}

int setPPTPEthernetUNIPauseTime(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr)
{
	int portId = 0;
	int ret = 0;
	uint16_t pauseTime = 0;
	uint16_t oldPauseTime = 0;
	omci_pptp_eth_uni_ptr pptp_eth_uni_attr = NULL;
	omci_me_info_t old_me_info = {0};
	omci_pptp_eth_uni_ptr old_pptp_eth_uni_attr = NULL;
	struct XMCS_TxQueueCongestion_S wanCongest;

	omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d]:Enter\n",__FUNCTION__,__LINE__);
    if(NULL == me_info  || NULL == omci_attr){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  parameter is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	pptp_eth_uni_attr = (omci_pptp_eth_uni_ptr)me_info->attributes;
    if(pptp_eth_uni_attr == NULL ){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  attributes is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	
	portId = getPortIdxByInstId(me_info->inst_id);
	if(portId <= 0) {  
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"[%s][%d]:  portId error\n",__FUNCTION__,__LINE__);
		ret = -1;
		goto end;
	}
	portId--;
	pauseTime = pptp_eth_uni_attr->pauseTime;
	omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d]:  portId =%d, pauseTime = %d\n",__FUNCTION__,__LINE__,portId,pauseTime);
	//api
	old_me_info.class_id = me_info->class_id;
	old_me_info.inst_id = me_info->inst_id;
	if(omci_attr_get_old_data_except_table_attr(&old_me_info) != 0){
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]get data failed.\n",__FUNCTION__,__LINE__);
		ret = -1;
		goto end;
	}
	old_pptp_eth_uni_attr = (omci_pptp_eth_uni_ptr)old_me_info.attributes;
	if(NULL == old_pptp_eth_uni_attr){
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "%s->old_pptp_eth_uni_attr calloc fail\n",__FUNCTION__);
		ret = -1;
		goto end;
	}
	oldPauseTime = old_pptp_eth_uni_attr->pauseTime;

	omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE,"\r\n setPPTPEthernetUNIPauseTime->oldPauseTime = %d, pauseTime = %d, [%d]",oldPauseTime, pauseTime, __LINE__);	

	if(oldPauseTime != pauseTime)
	{
		if(pSystemCap->ethType[portId] == UNIT_TYPE_BASET_10100 ||pSystemCap->ethType[portId] == UNIT_TYPE_BASET_101001000 ) {
			ret = macMT7530SetPauseTime(pauseTime, portId);
			if(ret == -1){
				omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"\r\n setPPTPEthernetUNIPauseTime->macMT7530SetPauseTime fail[%d]",__LINE__); 
			}
	                
	                /*need restart auto neg to let flow control function take effect*/
			ret = macMT7530PortAutoNegRestartAutoConfig(portId);
			if(ret == -1){
				omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"\r\n setPPTPEthernetUNIPauseTime->macMT7530PortAutoNegRestartAutoConfig fail[%d]",__LINE__); 
			}

			/*for green drop function handle, if pauseTime=0,will restore the green drop function, else will disable green drop function*/
			wanCongest.congestMode.threshold = pauseTime ? 1:0;
			ret = gponmgr_lib_set_congest_config(MASK_OF_CongestTrtcmMode,&wanCongest);
			omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE,"[%s][%s][%d]:pause=[%d],DropMode=%d!\n",__FILE__,__FUNCTION__, __LINE__, pauseTime, wanCongest.congestMode.threshold);
		}
		else if(pSystemCap->ethType[portId] == UNIT_TYPE_ETHER_2500) {
			;                                    //to be implemented
		}
		else if(pSystemCap->ethType[portId] == UNIT_TYPE_ETHER_10G) {
			;                                    //to be implemented
		}	
	}
end:	
	return ret;
}


int setPPTPEthernetUNIARCValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr)
{
	uint8_t arcValue = 0;
	int ret = -1;
	omci_pptp_eth_uni_ptr pptp_eth_uni_attr = NULL;
	evt_arc_data_t arc_data = {0};

	omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d]:Enter\n",__FUNCTION__,__LINE__);
    if(NULL == me_info  || NULL == omci_attr){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  parameter is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	pptp_eth_uni_attr = (omci_pptp_eth_uni_ptr)me_info->attributes;
    if(pptp_eth_uni_attr == NULL ){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  attributes is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	
	arc_data.class_id = me_info->class_id;
	arc_data.inst_id = me_info->inst_id;
	arc_data.interval = pptp_eth_uni_attr->arcInterval;

	arcValue = pptp_eth_uni_attr->arc;
	if(arcValue == 1){
		arc_data.arc_en = ARC_ENABLE;
		omci_adpt_report_event(OMCI_EVENT_ARC, &arc_data);
	}else if(arcValue == 0){
		arc_data.arc_en = ARC_DISABLE;
		omci_adpt_report_event(OMCI_EVENT_ARC, &arc_data);
	}else{
		return -1;
	}

	ret = 0;
end:	
	return ret;
}



/*******************************************************************************************************************************
9.5.5 Virtual Ethernet interface point

********************************************************************************************************************************/

int setVirtualEthernetInterfacePointAdminStateValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr)
{
//	uint16_t portId = 0;
//	notify_msg_t msg = {0};
	uint8_t oldValue = 0;
	uint8_t tmpValue = 0;
	int ret = -1;
	omci_veip_ptr veip_attr = NULL;
	omci_me_info_t old_me_info = {0};
	omci_veip_ptr old_veip_attr = NULL;
	evt_avc_data_t avc_data = {0};
	evt_alarm_data_t alarm_data = {0};
	
	omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d]:Enter\n",__FUNCTION__,__LINE__);
    if(NULL == me_info  || NULL == omci_attr){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  parameter is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	veip_attr = (omci_veip_ptr)me_info->attributes;
    if(veip_attr == NULL ){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  attributes is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }

//	portId = me_info->inst_id - 1;
	
	tmpValue = veip_attr->adminState;
	if(tmpValue == 0x0){//enable function
		//add api
	}
	else if(tmpValue == 0x1){//disable function
		//add api
	}
	else
	{
		return -1;
	}

	omci_lib_set_rdkb_veip_adminState(veip_attr->meId,&tmpValue);
	old_me_info.class_id = me_info->class_id;
	old_me_info.inst_id = me_info->inst_id;
	if(omci_attr_get_old_data_except_table_attr(&old_me_info) != 0){
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]get data failed.\n",__FUNCTION__,__LINE__);
		ret = -1;
		goto end;
	}
	old_veip_attr = (omci_veip_ptr)old_me_info.attributes;
	if(NULL == old_veip_attr){
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "%s->old_veip_attr calloc fail\n",__FUNCTION__);
		ret = -1;
		goto end;
	}
	oldValue = old_veip_attr->adminState;

	if(tmpValue != oldValue){
		/*deal with op state AVC, if admin state changes, we should send op state AVC*/
		avc_data.class_id = me_info->class_id;
		avc_data.inst_id = me_info->inst_id;
		avc_data.avc_index = OMCI_AVC_ID_VEIP_OPERATIONAL_STATE;
		omci_adpt_report_event(OMCI_EVENT_AVC, (void *)&avc_data);

		if(tmpValue == 0x1){//disable function
			/*deal with connection function fail ALARM*/
			alarm_data.class_id = me_info->class_id;
			alarm_data.inst_id = me_info->inst_id;
			alarm_data.alarm_num = OMCI_ALARM_ID_VEIP_CONNECTING_FUNCTION_FAIL;
			alarm_data.alarm_flag= OMCI_ALARM_HAPPEND;
		}
		else//enable function
		{
			/*deal with connection function fail ALARM*/
			alarm_data.class_id = me_info->class_id;
			alarm_data.inst_id = me_info->inst_id;
			alarm_data.alarm_num = OMCI_ALARM_ID_VEIP_CONNECTING_FUNCTION_FAIL;
			alarm_data.alarm_flag= OMCI_ALARM_CLEAR;
		}
		omci_adpt_report_event(OMCI_EVENT_ALARM, (void *)&alarm_data);	
	}
	ret = 0;
end:
	return ret;
}

int getVirtualEthernetInterfacePointOpStateValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr)
{
	uint8_t tmpValue = 0;
	int ret = -1;
	omci_veip_ptr veip_attr = NULL;

	omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d]:Enter\n",__FUNCTION__,__LINE__);
    if(NULL == me_info  || NULL == omci_attr){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  parameter is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	veip_attr = (omci_veip_ptr)me_info->attributes;
    if(veip_attr == NULL ){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  attributes is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	
	tmpValue = veip_attr->adminState;

	if(tmpValue == 0)
	{
		veip_attr->operationalState = 0x0;
	}
	else if(tmpValue == 1)
	{
		veip_attr->operationalState = 0x1;
	}	

end:	
	return ret;	
}

int setVirtualEthernetInterfacePointInterDomain(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr)
{
	int ret= 0;
	omci_veip_ptr veip_attr = NULL;

	omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d]:Enter\n",__FUNCTION__,__LINE__);
	if(NULL == me_info	|| NULL == omci_attr){
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  parameter is NULL, fail\n",__FUNCTION__,__LINE__);
		ret = -1;
		goto end;
	}
	veip_attr = (omci_veip_ptr)me_info->attributes;
	if(veip_attr == NULL ){
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  attributes is NULL, fail\n",__FUNCTION__,__LINE__);
		ret = -1;
		goto end;
	}

	omci_lib_set_rdkb_veip_interdomain_name(veip_attr->meId,veip_attr->interdomainName);

end:
	return ret;
}
int getVirtualEthernetInterfacePointIANAAssignedPortValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr)
{
	char tmpValue[8] = {0};
	uint16_t tmpPort = 0x0;
	int ret= -1;
	omci_veip_ptr veip_attr = NULL;

	omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d]:Enter\n",__FUNCTION__,__LINE__);
    if(NULL == me_info  || NULL == omci_attr){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  parameter is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	veip_attr = (omci_veip_ptr)me_info->attributes;
    if(veip_attr == NULL ){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]:  attributes is NULL, fail\n",__FUNCTION__,__LINE__);
        ret = -1;
        goto end;
    }
	
	if(omci_tcapi_nget("Cwmp_Entry", "conReqPort", tmpValue,sizeof(tmpValue)) != 0)
		veip_attr->ianaAssignedPort = 0xFFFF;
	else
	{
		tmpPort = (uint16_t)atoi(tmpValue);
		omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE,"\r\n tmpPort:%X \r\n", tmpPort);
		veip_attr->ianaAssignedPort = tmpPort;
	}
	ret = 0;
end:	
	return ret;	
}
